///Project: Introducing GLP Paper Table 2 
///Date:07 29 2018 
///Stata14 


********TABLE 2*************
clear all 
use "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/GLP_person_18 07 29.dta"
/*count if power==1
count if power==3
count if office1==2|office2==2|office3==2
count if office1==7|office2==7|office3==7
count if office1==6|office2==6|office3==6
count if wealth==0
count if wealth==1
count if region==1
count if region==2
count if region==3
count if region==4
count if region==5
count if regime==0
count if regime==1*/
***Row 1: Age***
preserve
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
restore
**By Offices**
**Apex**
preserve
keep if power==1
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
restore
**Top Ten**
preserve
keep if power==3
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
restore
**Cabinet**
preserve
keep if  office1==2 |office2==2| office3==2
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
restore
**Supreme Court**
preserve
keep if  office1==7 |office2==7| office3==7
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
restore
**MPs**
preserve
keep if  office1==6|office2==6| office3==6
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
restore
**By Wealth**
**Non-Oecd**
preserve
keep if wealth==0
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
count
restore
**Oecd**
preserve
keep if wealth==1
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
restore
**By Region**
preserve
forvalues x=1/5 {
clear all
use"/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/GLP_person_18 07 29.dta"
keep if region==`x'
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
}
restore
**By Regime**
**Democracy**
preserve
keep if regime==0
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
restore
count
**Non-democracies**
preserve
keep if regime==1
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
restore

***Row 2: Gender***
preserve
//drop if gender==.
collapse (sum) male=male female=female, by(country country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
restore 
**By Offices**
**Apex**
preserve
keep if power==1
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
restore
**Top Ten**
preserve
keep if power==3
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
restore
**Cabinet**
preserve
keep if office1==2 |office2==2| office3==2
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
restore
**Supreme Court**
preserve
keep if office1==7 |office2==7| office3==7
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
restore
**MPs**
preserve
keep if office1==6 |office2==6| office3==6
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
restore
**By Wealth**
**nonoecd**
preserve
keep if wealth==0
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
restore
**oecd**
preserve
keep if wealth==1
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
restore
**By Region**
preserve
forvalues x=1/5 {
clear all
use "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/GLP_person_18 07 29.dta"
keep if region==`x'
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
}
restore
** By Regime**
**Democracy**
preserve
keep if regime==0
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
restore
**Non-democracies**
preserve
keep if regime==1
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
restore

***Row 3: Marital Status***ASK JOHN 
clear all 
use "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/GLP_person_18 07 29.dta"
drop if marital_status==.
/*gen temp=1
sort country_nid 
by country_nid: egen married_persons=total(temp)
gen percent=married_persons/country_num_persons
drop if percent<0.75*/
gen married=0
replace married=1 if marital_status==2
gen nonmarried=0
replace nonmarried=1 if marital_status==1|marital_status==3|marital_status==4
sort marital_status 
preserve
collapse (sum) married=married nonmarried=nonmarried, by(country country_nid)
gen total=married+nonmarried
gen prcmarried=married/total*100
sum prcmarried
restore
//Offices
**Apex**
preserve
keep if power==1
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total*100
sum prcmarried
restore
**Top Ten**
preserve
keep if power==3
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total*100
sum prcmarried
restore
**cabinet**
preserve
keep if office1==2 |office2==2| office3==2
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total*100
sum prcmarried
restore
**Supreme Court**
preserve
keep if office1==7 |office2==7| office3==7
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total*100
sum prcmarried
restore
**MPs**
preserve
keep if office1==6 |office2==6| office3==6
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total*100
sum prcmarried
restore
//Wealth
**nonoecd**
preserve
keep if wealth==0
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total*100
sum prcmarried
restore
**oecd**
preserve
keep if wealth==1
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total*100
sum prcmarried
restore
//Region 
preserve 
forvalues x=1/5 {
clear all
use "/Users/erzeno/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Publication/PoP/Submission 2 (Bernhard)/Round 3/Replicationdata/GLP_person_18 07 29.dta"
gen married=0
replace married=1 if marital_status==2
gen nonmarried=0
replace nonmarried=1 if marital_status==1|marital_status==3|marital_status==4
keep if region==`x'
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total*100
sum prcmarried
}
restore
//Regime
**Democracy**
preserve
keep if regime==0
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total*100
sum prcmarried
restore
**Authoriatarian**
preserve
keep if regime==1
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total*100
sum prcmarried
restore

